#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy  as np
import pandas as pd
import talib as ta

eps = 1e-8

def signal(*args):
    # Clv 指标
    df = args[0]
    n = args[1]
    factor_name = args[2]

    # CLV=(2*CLOSE-LOW-HIGH)/(HIGH-LOW)
    df['CLV'] = (2 * df['close'] - df['low'] - df['high']) / (df['high'] - df['low'])
    df[factor_name] = df['CLV'].rolling(n, min_periods=1).mean()  # CLVMA=MA(CLV,N)

    # 删除多余列
    del df['CLV']

    return df
